﻿Public Class vbp


#Region "Regex"

    Public Function GetRegQForGenericLine() As String
        'esempio:
        'Module=BtrApi32; ..\..\pervasive\BtrApi32.bas
        'Class=API_Directory; class\API_Directory.cls
        Return "(?<percorso>.+)"

    End Function


    ''' <summary>
    ''' Trasforma una riga che inizia con Module in una riga batch
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GetRegQForKeyModule() As String
        'esempio:
        'Module=BtrApi32; ..\..\pervasive\BtrApi32.bas
        'Class=API_Directory; class\API_Directory.cls
        Return "(Module|Class)=.+;\s+(?<percorso>.+)"

    End Function

    Public Function GetRegQForKeyObject() As String
        'esempio:
        'Object={F83FB95C-D981-11D2-A80A-00104BF191A4}#1.0#0; SKCL.dll
        'Object={F5323D49-E6F5-4421-80D3-0DA58EE71888}#1.8#0; Iatros.MediciInRete.UCWrap.tlb
        Return "(Object)=\{(?<classID>[0-9|-]+)\}#.+#.+; (?<percorso>.+)"
    End Function

    Public Function GetRegQForKeyReference() As String
        'esempio:
        'Reference=*\G{E1FD865D-707B-4581-BD25-2167B1EBAA61}#1.0#0#..\..\dotNet\Sogei\Iatros.Ulss9\Iatros.Ulss9\bin\Release\Iatros.Ulss9.tlb#Iatros.Ulss9
        'Return "(Reference)=(?<percorso>.+)"
        '"Reference=*\\G{(?<classID>.+)\}#(?<version>[0-9|\.]+)#(?<subversion>[0-9|\.]+)#(?<percorso>.+)#(?<nome>.+)"
        Return "Reference=*\\G\{(?<classID>.+)\}#(?<version>.+)#(?<subversion>.+)#(?<percorso>.+)#(?<nome>.+)"
    End Function

    Public Function GetRegQForKeyForm() As String
        'esempio:
        'Form=UI\frmFarma.frm
        'UserControl=UI\userControls\myButton.ctl
        Return "(UserControl|Form)=(?<percorso>.+)"
    End Function

    Public Function GetRegQForKeyRelatedDoc() As String
        'esempio:
        'Form=UI\frmFarma.frm
        'UserControl=UI\userControls\myButton.ctl
        Return "(RelatedDoc)=(?<percorso>.+)"
    End Function

    Public Function GetRegQForVersionInfo() As String
        'esempio:
        'MajorVer = 2
        'MinorVer = 0
        'RevisionVer = 5
        'MajorVer.*=.*\d.*\nMinorVer=.*\d.*\nRevisionVer.*=.*\d
        Return "MajorVer.*=.*(?<MajorVer>\d+).*\nMinorVer=.*(?<MinorVer>\d+).*\nRevisionVer.*=.*(?<RevisionVer>\d)"
        'Return "(MajorVer )= (?<MajorVer>.+)\n(MinorVer )= (?<MinorVer>.+)\n(RevisionVer )= (?<RevisionVer>.+)\n"
    End Function

#End Region

#Region "immagazzinamento dati"

    Public Class percorsiVbp

        Public Sub New(ByVal name As String)
            _name = name
        End Sub

        Private _name As String
        Public Property Name() As String
            Get
                Return _name
            End Get
            Set(ByVal value As String)
                _name = value
            End Set
        End Property

    End Class
#End Region




End Class

Public Class analisiVBP

    Public vbpFiles As List(Of String)
    Public vbpObj As List(Of String)
    Public vbpRef As List(Of reference)

    Sub New()
        vbpFiles = New List(Of String)
        vbpObj = New List(Of String)
        vbpRef = New List(Of Reference)
    End Sub


End Class

Public Class Reference
    Implements IComparable

    Private rsplittato As String()

    Public Property percorso As String
    Public Property nome As String
    Public Property versione As String
    Public Property subversion As String



    Sub New()

    End Sub

    Sub New(r As String)
        rsplittato = r.Split("#")

        percorso = rsplittato(3)
        nome = rsplittato(4)
        versione = rsplittato(1)
        subversion = rsplittato(2)

    End Sub


    Private Overrides Function CompareTo(ByVal obj As Object) As Integer Implements IComparable.CompareTo

        If obj Is Nothing Then Return 1
        Dim other As Reference = DirectCast(obj, Reference)
        Return StrComp(Me.nome, other.nome, CompareMethod.Text)

    End Function

    Public Function ToLower() As Reference
        Dim tmp As New Reference

        tmp.percorso = percorso.ToLower
        tmp.nome = nome.ToLower
        tmp.versione = versione.ToLower
        tmp.subversion = subversion.ToLower

        Return tmp

    End Function





    Public Function CompareTo(obj As Object) As Integer Implements System.IComparable.CompareTo

    End Function
End Class